package com.cssl.controller;

import cn.hutool.core.util.ObjectUtil;

import com.cssl.domain.dto.UserAccountDto;
import com.cssl.domain.dto.UserAccountTraceDto;
import com.cssl.service.DtsAccountTraceService;
import com.cssl.service.DtsUserAccountService;
import com.cssl.util.InfoCode;
import com.cssl.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/usersaccounttrace")
public class DtsAccountTraceController {

    @Autowired
    private DtsAccountTraceService dtsAccountTraceService;

    @PostMapping("/List")
    public Result getAccountTraceList(@RequestBody UserAccountDto userAccountDto) {
        Map accountTraceList = dtsAccountTraceService.getAccountTraceList(userAccountDto);
        if (ObjectUtil.isEmpty(accountTraceList.get("list"))) {
            return Result.result(InfoCode.QUERY_EMPTY, InfoCode.MESSAGE_QUERY_EMPTY, null, System.currentTimeMillis());
        }
        return Result.result(InfoCode.OK, InfoCode.MESSAGE_OK, accountTraceList, System.currentTimeMillis());

    }

    @PostMapping("/approve")
    public Result approveAccountTrace(@RequestBody UserAccountTraceDto traceDto) {
        return dtsAccountTraceService.approveAccountTrace(traceDto);

    }
}
